<?xml version="1.0" encoding="UTF-8"?><d:tdl xmlns="http://www.w3.org/1999/xhtml" xmlns:b="http://www.backbase.com/2006/btl" xmlns:d="http://www.backbase.com/2006/tdl"   xmlns:bf="http://www.backbase.com/2007/forms">

	<d:namespace name="http://www.backbase.com/2006/btl">
		<d:uses element="visualElement" src="../../www.backbase.com.2006.btl/visualElement/visualElement.xml"/>
	</d:namespace>

	<d:namespace name="http://www.backbase.com/2007/forms">

		<d:uses interface="iMessages iMessage" src="forms.xml"/>

		<d:resource type="text/javascript"><![CDATA[
			if (!window.BBForms)
				BBForms = {};
			BBForms.message = {};
			BBForms.message.facets = {required: 1, schema: 2};
		]]></d:resource>

		<!-- Implement bf:iMessages and bf:iMessage -->
		<d:element name="messages" extends="b:visualElement" implements="bf:iMessages">
			
			<d:template type="application/xhtml+xml">
				<div style="display:inline"><d:content/></div>
			</d:template>

			<d:property name="messages">
				<d:getter type="text/javascript"><![CDATA[
					var aMessages = [];
					var aChildren = this.getProperty('childNodes');
					for(var i=0, l = aChildren.length; i < l; i++)
						if( bb.instanceOf( aChildren[i], 'http://www.backbase.com/2007/forms', 'message'))
							aMessages[aMessages.length] = aChildren[i];
					return aMessages;
				]]></d:getter>
			</d:property>

			<d:method name="handleValidityChanged">
				<d:argument name="event"/>
				<d:body type="text/javascript"><![CDATA[
					var messages = this.getProperty('messages');
					var selectedMessage = null;
					for (var i = 0, length = messages.length; i < length; i++) {
						if (messages[i].getProperty('event') == event.type) {
							if (messages[i].getProperty('facet') == event.detail)
								selectedMessage = messages[i];
							else
								selectedMessage = selectedMessage || messages[i];
						}
					}
					for (var i = 0, length = messages.length; i < length; i++) {
						if (messages[i] == selectedMessage)
							messages[i].show();
						else
							messages[i].hide();
					}
				]]></d:body>
			</d:method>
		</d:element>

		<d:element name="message" extends="b:visualElement" implements="bf:iMessage">
			

			<d:template type="application/xhtml+xml">
				<span style="display:none;"><d:content/></span>
			</d:template>

			<d:attribute name="event">
				
			</d:attribute>

			<d:attribute name="facet">
				
			</d:attribute>

			<d:property name="event">
				<d:getter type="text/javascript"><![CDATA[
					return this.getAttribute('event');
				]]></d:getter>
			</d:property>

			<d:property name="facet">
				<d:getter type="text/javascript"><![CDATA[
					var facet = this.getAttribute('facet');
					return BBForms.message.facets[facet] || 0;
				]]></d:getter>
			</d:property>

			<d:method name="show">
				<d:body type="text/javascript"><![CDATA[
					this.viewNode.style.display = 'inline';
				]]></d:body>
			</d:method>

			<d:method name="hide">
				<d:body type="text/javascript"><![CDATA[
					this.viewNode.style.display = 'none';
				]]></d:body>
			</d:method>
		</d:element>

	</d:namespace>
</d:tdl>